unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, rtcDataSrv, rtcInfo, rtcConn, rtcHttpSrv,
  RzButton, RzRadChk;

type
  TForm1 = class(TForm)
    HtpSrv_1: TRtcHttpServer;
    RtcDataProvider1: TRtcDataProvider;
    Chkb_1: TRzCheckBox;
    procedure RtcDataProvider1CheckRequest(Sender: TRtcConnection);
    procedure Chkb_1Click(Sender: TObject);
    procedure RtcDataProvider1DataReceived(Sender: TRtcConnection);
  private
  public
  end;

var
  Form1: TForm1;

implementation

uses
  Class_KzUtils;

{$R *.dfm}

procedure TForm1.Chkb_1Click(Sender: TObject);
begin
  //
  if TRzCheckBox(Sender).Checked then
  begin
    self.HtpSrv_1.ServerPort:='9001';
    self.HtpSrv_1.Listen();
  end else
  begin
    self.HtpSrv_1.StopListen;
  end;
end;

procedure TForm1.RtcDataProvider1CheckRequest(Sender: TRtcConnection);
var
  FileName:string;
begin
  with TRtcDataServer(Sender) do
  begin
    FileName:=UpperCase(Request.FileName);
    Accept;
  end;
end;

procedure TForm1.RtcDataProvider1DataReceived(Sender: TRtcConnection);
var
  DataServer:TRtcDataServer absolute Sender;
begin
  if DataServer.Request.Complete then
  begin
    //DataServer.Write('true');
    DataServer.Write(Read_File(TKzUtils.ExePath+'10001.jpg'));
  end;
end;

end.
